package qqgroupdata.process.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import qqgroupdata.process.common.JsonResult;
import qqgroupdata.process.model.QQNum;
import qqgroupdata.process.model.Qun;
import qqgroupdata.process.service.DbDataSelectService;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/data")
public class SelectDataController {
    @Resource
    DbDataSelectService dbDataSelectService;

    @RequestMapping("/qun")
    public JsonResult qun(Integer num) {
        if (num == null || num <= 0) {
            return JsonResult.error("群号码错误");
        }
        List<Qun> quns = dbDataSelectService.selectQqun(num);
        return JsonResult.success(quns);
    }

    @RequestMapping("/qqnum")
    public JsonResult qqnum(Integer num) {
        if (num == null || num <= 0) {
            return JsonResult.error("QQ号码错误");
        }
        List<QQNum> qqNums = dbDataSelectService.selectQQNum(num);
        return JsonResult.success(qqNums);
    }
}
